const path = require('path');
const log4js = require("log4js");
log4js.configure({
    appenders: {
        console: { type: "console" },
        oa: {
            type: "dateFile",
            filename: path.join(__dirname, '../logs/oa'),
            pattern: "yyyy-MM-dd.log",
            alwaysIncludePattern: true,
            numBackups: 10
        }
    },
    categories: {
        default: {
            appenders: ["oa", "console"],
            level: "debug"
        },
        development: {
            appenders: ["oa", "console"],
            level: "debug"
        },
        production: {
            appenders: ["oa", "console"],
            level: "info"
        }
    },
    pm2: true,
    pm2InstanceVar: "INSTANCE_ID"
  });

let logger = log4js.getLogger(process.env.NODE_ENV || 'development');

module.exports = logger;
